﻿#ifndef __SS_THREAD_CONDITION_H__
#define __SS_THREAD_CONDITION_H__
#include "ssThreadLock.h"

namespace StarSeeker
{

class ssThreadCondition
{
public:
	ssThreadCondition(void);
	ssThreadCondition(ssThreadLock* lk);
	~ssThreadCondition(void);
	//绑定线程锁
	void BindLock(ssThreadLock* lk);
	//永久等待唤醒
	void Wait();
	//等待一定时间后唤醒
	void WaitTime(unsigned int msec);
	//唤醒一个相关线程
	void NotifyOne();
	//唤醒所有相关线程的一个
	void NotifyAll();

private:
	ssThreadLock	*				m_pLock; //线程锁
#ifdef SS_USE_BOOST_THREAD
	boost::condition_variable_any	m_cond; //条件变量
#elif defined _WIN32
	CONDITION_VARIABLE				m_cond;
#else
	pthread_cond_t					m_cond;
#endif
};

}
#endif
